package com.qumap.edititem.update.callback;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.qumap.edititem.EditItemDisplay;
import com.qumap.item.ItemOnMap;
import com.qumap.item.event.ItemEvent;
import com.qumap.item.event.ItemEventCollection;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: 28.05.11
 * Time: 10:20
 * To change this template use File | Settings | File Templates.
 */
public abstract class ChangeCallback<T> implements AsyncCallback<T> {

    protected EditItemDisplay display;
    protected ItemOnMap update_item;


    public void setDisplay(EditItemDisplay display) {
        this.display = display;
    }

    public void setItem(ItemOnMap item) {
        this.update_item = item;
    }

    public void init() {

    }

    protected void sendSelectEvent(ItemOnMap selected_item) {
        ItemEvent item_selected_event = ItemEventCollection.getCollection().getEvent(ItemEventCollection.EventType.Select);
        item_selected_event.add(selected_item);
        sendItemEvent(item_selected_event);
    }

    protected void sendItemEvent(ItemEvent event) {
        display.fireEvent(event);
    }
}
